#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main()
{
      int id = fork();
      if(id > 0)
      {
        printf("父进程,pid是:%d,ppid是:%d\n",getpid(),getppid());
        sleep(3);
        exit(1);  
      }
      else if(id==0)
      {
        while(1)
        {
           printf("子进程,pid是:%d,ppid是:%d\n",getpid(),getppid());
           sleep(1);                       
        }           
      }
      return 0;
}

/*
 * 僵尸进程的学习
int main()
{
  int id = fork();
  if(id == 0)
  {
    printf("子进程,pid是:%d,ppid是:%d\n",getpid(),getppid());
    sleep(3);
    exit(1);
  }
  else if(id>0)
  {
    while(1)
    {
      printf("父进程,pid是:%d,ppid是:%d\n",getpid(),getppid());
      sleep(1);
    }
  }
  return 0;
}*/  
/*int main()
{
  printf("hello gdb\n");
  printf("hello gdb\n");
  printf("hello gdb\n");
  printf("hello gdb\n");
  printf("hello gdb\n");
  printf("hello gdb\n");
  printf("hello gdb\n");
  printf("hello gdb\n");
  printf("hello gdb\n");
  printf("hello gdb\n");
  printf("hello gdb\n");
  return 0;
}*/
